import http from "@/utils/request";
import {url} from "@/services/Agents/index";

export async function getMachines(current = 1, page_size = 50): Promise<API.Result> {
    /** 获取设备列表 */
    return http.get(`${url}/machines`, {params: {current, page_size}});
}

export async function getUnbound(current = 1, page_size = 50): Promise<API.Result> {
    /** 设备绑定 */
    return http.get(`${url}/machines/unbound`, {params: {current, page_size}});
}

export async function storeBindMachine(id: number, device_key: string, device_password: string): Promise<API.Result> {
    /** 设备绑定 */
    return http.put(`${url}/machines/bind_machine/${id}`, {device_key, device_password});
}

export async function unbindMachine(storeId: number, machineId: number): Promise<API.Result> {
    /** 设备绑定 */
    return http.delete(`${url}/machines/unbind?id=${storeId}&machine_id=${machineId}`);
}